<?
/**
 * GDataGridActionOptions
 */
class GDataGridImage extends GDataGridColumn{
	public $src=NULL;
	public $width=NULL;
	public $height=NULL;
	public $alt=NULL;
	public $href=NULL;
	public $target=NULL;
	public $class=NULL;
	public $id=NULL;
	public $confirm=NULL;
	public $extra=NULL;
	public function __construct($src=NULL,$width=NULL,$height=NULL,$alt=NULL,$href=NULL,$target=NULL,$class=NULL,$id=NULL,$extra=NULL){
		$this->setSrc($src);
		$this->setWidth($width);
		$this->setHeight($height);
		$this->setAlt($alt);
		$this->setHref($href);
		$this->setTarget($target);
		$this->setClass($class);
		$this->setId($id);
		$this->setExtra($extra);
	}

	public function getSrc(){
		return($this->src);
	}
	public function setSrc($value){
		$this->src=$value;
	}

	public function getWidth(){
		return($this->width);
	}
	public function setWidth($value){
		$this->width=$value;
	}

	public function getHeight(){
		return($this->height);
	}
	public function setHeight($value){
		$this->height=$value;
	}

	public function getAlt(){
		return($this->alt);
	}
	public function setAlt($value){
		$this->alt=$value;
	}

	public function getHref(){
		return($this->href);
	}
	public function setHref($href){
		$this->href=$href;
	}

	public function getTarget(){
		return($this->target);
	}
	public function setTarget($target){
		$this->target=$target;
	}

	public function getClass(){
		return($this->class);
	}
	public function setClass($class){
		$this->class=$class;
	}

	public function getId(){
		return($this->id);
	}
	public function setId($id){
		$this->id=$id;
	}

	public function getConfirm(){
		return($this->confirm);
	}
	public function setConfirm($confirm){
		$this->confirm=$confirm;
	}

	public function getExtra(){
		return($this->extra);
	}
	public function setExtra($extra){
		$this->extra=$extra;
	}

	public function toHtml($row){
		$hasLink=false;
		$result="";
		$href=$this->getHref();
		if($href!==NULL){
			$result.="<a href=\"".$href."\"";
		}
		$target=$this->getTarget();
		if($target!==NULL){
			$result.=" target=\"".$target."\"";
		}
		$class=$this->getClass();
		if($class!==NULL){
			$result.=" class=\"".$class."\"";
		}
		$id=$this->getId();
		if($id!==NULL){
			$result.=" id=\"".$id."\"";
		}
		$confirm=$this->getConfirm();
		if($confirm!==NULL){
			$result.=" onclick=\"return(confirm('$confirm'));\"";
		}
		$extra=$this->getExtra();
		if($extra!==NULL){
			$result.=" $extra";
		}
		if(strlen($result)>0){
			$result.=">";
			$hasLink=true;
		}
		$src=$this->getSrc();
		if($src!==NULL){
			$result.='<img src="'.$src.'" border="0"';
			$width=$this->getWidth();
			if($width!==NULL){
				$result.=" width=\"$width\"";
			}
			$height=$this->getHeight();
			if($height!==NULL){
				$result.=" height=\"$height\"";
			}
			$alt=$this->getAlt();
			if($alt!==NULL){
				$result.=" alt=\"$alt\"";
			}
			$result.=' />';
		}
		if($hasLink){
			$result.="</a>";
		}
		if(preg_match_all('/##([^#]+)##/',$result,$matches)){
			$matches=$matches[1];
			for($c=0;$c<count($matches);$c++){
				$match=$matches[$c];
				$replace="";
				if($match=="id"){
					$replace=model::numencrypt($row["id"],$row["dateAdded"]);
				}else{
					$replace=$row[$match];
				}
				$result=preg_replace("/##$match##/",$replace,$result);
			}
		}
		return($result);
	}
};
?>
